import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop012_搜索商品"
firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox, "商品管理", "管理商品")
# 1.选择商品名称，输入“美的”，点击“搜索”按钮。
firefox.find_element_by_xpath("//input[@name='goods_name']").send_keys("美的")
time.sleep(3)
firefox.find_element_by_xpath('//button').click()
time.sleep(10)
# firefox.find_element_by_xpath("//button[@class='btn btn-small btn-primary']").click()
# 2.搜索成功美的的后台商品 > 搜索成功美的商品。
# try:
#     firefox.find_element_by_xpath("//td[text()='%s%']"%'美的')
#     writeLog("%s 测试通过" % testCase)
# except:
#     writeLog("%s 测试失败" % testCase)
#     getPhoto(firefox)
# firefox.quit()
ss = firefox.find_element_by_xpath("//tr[2]/td[3]").text
print(ss)
try:
    if "美的" in ss:
        writeLog("%s 测试通过" % testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()